package com.zhou.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhou.api.dto.WareHouseExamineDTO;
import com.zhou.api.entity.WareHouse;
import com.zhou.result.R;
import com.zhou.service.WareHouseService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description : 仓库管理
 * @Author : zyy
 * @Date: 2024/7/25  9:19
 */
@RestController
@RequestMapping("wareHouse")
@Api(tags = "仓库管理")
public class WareHouseController {

    @Resource
    private WareHouseService wareHouseService;

    /**
     * 添加物品
     *
     * @param goods
     * @param nums
     * @return
     */
    @PostMapping("add")
    @Operation(summary = "添加物品")
    public String add(@RequestParam @Parameter(description = "物品") String goods, @RequestParam @Parameter(description = "总数") Integer nums) {
        return wareHouseService.add(goods, nums);
    }

    /**
     * 修改物品
     *
     * @param id
     * @param goods
     * @param nums
     * @return
     */
    @PostMapping("update")
    @Operation(summary = "修改物品")
    public String update(@RequestParam @Parameter(description = "id") String id, @RequestParam @Parameter(description = "物品") String goods, @RequestParam @Parameter(description = "总数") Integer nums) {
        return wareHouseService.update(id, goods, nums);
    }

    /**
     * 真删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("delete/{id}")
    @Operation(summary = "删除物品")
    public String delete(@PathVariable("id") @Parameter(description = "id") String id) {
        return wareHouseService.delete(id);
    }

    /**
     * 软删除
     *
     * @return
     */
    @PutMapping("update")
    @Operation(summary = "软删除")
    public String update(@RequestParam @Parameter(description = "id") String id) {
        return wareHouseService.updateRemove(id);
    }

    /**
     * 获取列表
     * @param page 分页查询
     * @param status 状态
     * @param goods 物品
     * @return
     */
    @GetMapping("getList")
    @Operation(summary = "获取列表")
    public R<Page<WareHouse>> getList(Page page, @RequestParam(required = false) String status,
                                      @RequestParam(required = false) String goods) {
        return wareHouseService.getList(page, status, goods);
    }

    /**
     * 审核
     * @param dto
     * @return
     */
    @PostMapping("examine")
    @Operation(summary = "审核")
    public R examine(@RequestBody WareHouseExamineDTO dto) {
        return R.success(wareHouseService.examine(dto));
    }

    /**
     *
     */
}
